package com.elai.baseconfig.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.elai.common.annotation.Log;
import com.elai.common.core.controller.BaseController;
import com.elai.common.core.domain.AjaxResult;
import com.elai.common.enums.BusinessType;
import com.elai.baseconfig.domain.ChannelPushConfig;
import com.elai.baseconfig.service.IChannelPushConfigService;
import com.elai.common.utils.poi.ExcelUtil;
import com.elai.common.core.page.TableDataInfo;

/**
 * 推送参数配置Controller
 * 
 * @author elai
 * @date 2021-09-03
 */
@RestController
@RequestMapping("/baseconfig/pushconfig")
public class ChannelPushConfigController extends BaseController
{
    @Autowired
    private IChannelPushConfigService channelPushConfigService;

    /**
     * 查询推送参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelPushConfig channelPushConfig)
    {
        startPage();
        List<ChannelPushConfig> list = channelPushConfigService.selectChannelPushConfigList(channelPushConfig);
        return getDataTable(list);
    }

    /**
     * 导出推送参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:export')")
    @Log(title = "推送参数配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ChannelPushConfig channelPushConfig)
    {
        List<ChannelPushConfig> list = channelPushConfigService.selectChannelPushConfigList(channelPushConfig);
        ExcelUtil<ChannelPushConfig> util = new ExcelUtil<ChannelPushConfig>(ChannelPushConfig.class);
        return util.exportExcel(list, "推送参数配置数据");
    }

    /**
     * 获取推送参数配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(channelPushConfigService.selectChannelPushConfigById(id));
    }

    /**
     * 新增推送参数配置
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:add')")
    @Log(title = "推送参数配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelPushConfig channelPushConfig)
    {
        return toAjax(channelPushConfigService.insertChannelPushConfig(channelPushConfig));
    }

    /**
     * 修改推送参数配置
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:edit')")
    @Log(title = "推送参数配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelPushConfig channelPushConfig)
    {
        return toAjax(channelPushConfigService.updateChannelPushConfig(channelPushConfig));
    }

    /**
     * 删除推送参数配置
     */
    @PreAuthorize("@ss.hasPermi('baseconfig:pushconfig:remove')")
    @Log(title = "推送参数配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelPushConfigService.deleteChannelPushConfigByIds(ids));
    }
}
